package com.lds.xiaohashu.auth.controller;


import com.lds.framework.biz.operationlog.aspect.ApiOperationLog;
import com.lds.framework.common.response.Response;
import com.lds.xiaohashu.auth.model.vo.user.UserLoginReqVO;
import com.lds.xiaohashu.auth.model.vo.user.UserPasswordUpdateReqVO;
import com.lds.xiaohashu.auth.service.AuthService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author lds
 * @since 2024-11-08
 */
@Slf4j
@RestController
public class AuthController {
    @Resource
    private AuthService authService;

    @PostMapping("/login")
    @ApiOperationLog(description = "用户登录/注册")
    public Response<String> loginAndRegister(@Validated @RequestBody UserLoginReqVO userLoginReqVO) {
        return authService.loginAndRegister(userLoginReqVO);
    }

    @PostMapping("/logout")
    @ApiOperationLog(description = "账号登出")
    public Response<String> logout() {
        return authService.logout();
    }

    @PutMapping("/password/update")
    @ApiOperationLog(description = "修改密码")
    public Response<String> updatePassword(@Validated @RequestBody UserPasswordUpdateReqVO userPasswordUpdateReqVO) {
        return authService.updatePassword(userPasswordUpdateReqVO);
    }
}
